package com.crm.domain.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ActiveDTO implements Serializable {
    //活动ID
    private Integer id;
    //活动编号
    private String code;

    // 活动名称
    private String name;
    // 活动信息
    private String info;
    // 渠道
    private String channel;
    // 折扣
    private Double discount;
    // 开始时间
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm")
    private LocalDateTime beginTime;
    // 结束时间
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm")
    private LocalDateTime endTime;
    // 如果需要保留原始 activityTime 数组
    private List<String> activityTimes;
    // 状态
    private String status;
    // 类型
    private String type;

    // 可以添加一个构造函数来直接初始化 beginTime 和 endTime 从 activityTimes
    public ActiveDTO(String name, String info, String channel, Double discount, List<String> activityTimes, String status, String type) {
        this.name = name;
        this.info = info;
        this.channel = channel;
        this.discount = discount;
        if (activityTimes != null && activityTimes.size() >= 2) {
            this.beginTime = LocalDateTime.parse(activityTimes.get(0));
            this.endTime = LocalDateTime.parse(activityTimes.get(1));
        }
        this.activityTimes = activityTimes;
        this.status = status;
        this.type = type;
    }
}